$(function(){
	$("#loginButton").click(function(){
		//获取邮箱
		var email = $("#email").val();
		//获取密码
		var password = $("#password").val();
		if(!email){
			alert("请输入邮箱");
			return;
		}
		if(!password){
			alert("请输入密码");
			return;
		}
		//AJAX调用后台接口
		$.ajax({
			url:'/api/user/login/'+email+'/'+password+'',
			type:'POST',
			success:function(data){
				if(data == "用户名或密码错误"){
					alert(data);
				}else{
					alert("跳转首页");
					window.location.href = "index.html";
				}
			},
			error:function(err){
			    alert(err.responseText);
			}
		})
	})
	$("#newButton").click(function(){
		alert("跳转注册页面");
		window.location.href = "register.html";
	})
})